package com.canal.admin.controller;

import com.canal.admin.exception.BuzException;
import org.springframework.stereotype.Component;
import org.springframework.validation.BindingResult;

/**
 * 基础控制
 * @author yangbo
 * @date 2020-06-23 14:46
 */
@Component
public class BaseController {

    /**
     * 处理请求参数错误
     * @param result
     * @throws BuzException
     */
    protected void dealReqInvalidError(BindingResult result) throws BuzException {
        if(result.hasErrors()) {
            throw new BuzException(400,result.getAllErrors().get(0).getDefaultMessage());
        }
    }
}
